home *** CD-ROM | disk | FTP | other *** search
- From: root@205.218.34.39 (where is my fish?)
- Subject: Re: a C++ beginner question
- Newsgroups: comp.lang.c++
- References: <4ggmem$5dc@leol.net-link.net>
- Reply-To: wjl@sisna.com
- X-Newsreader: TIN [version 1.2 PL2]
- NNTP-Posting-Host: dialup1339.sisna.com
- Message-ID: <313fd18c.0@news.sisna.com>
- Date: 8 Mar 96 06:19:56 GMT
- Path: 205.218.34.39!root
-
- Jonathan S. Nachtigal (jnachtig@serv01.net-link.net) wrote:
- : Could someone please tell me how to do fractorial on C++.
- : Thank you :)
-
- Unless there is a function for doing factorials directly, which I don't
- believe there is, I'd just use something like this, using really whatever
- types you want, if you don't like these:
-
- unsigned long factorial(unsigned char c) {
- for (unsigned long f = c;c>1;--c) f *= c;
- return f;
- }
-
- Nothing special about it being C++, unless you wanted a factorial class, which
- is pretty silly. :)
-
- --
- where is my fish?
- wjl@sisna.com
- wjl@blarg.net
- wjl@byu.edu
-